package 构建模式;

import testJ.test1;

/**
 * 在不修改原有类的基础上，将功能符加到对像上
 * 装饰器类既调用原来的类的基础方法，并在这个方法的基础上进行封装
 */
public class 装饰器模式 {
    public static void main(test1[] args) {
        Component conreeteDecorator1 = new ConreeteDecorator1(new ConcreteComponent());
        conreeteDecorator1.operation();
    }
}
interface Component{
    void operation();
}
class ConcreteComponent implements Component{

    @Override
    public void operation() {
        System.out.println("拍照");
    }
}
abstract class Decorator implements Component{
    Component component;
    public Decorator(Component component){
        this.component = component;
    }
}
class ConreeteDecorator1 extends Decorator{

    public ConreeteDecorator1(Component component) {
        super(component);
    }

    @Override
    public void operation() {
        System.out.println("添加美颜效果");
        component.operation();
    }
}